package com.atguigu.day08.bean.test08;

import com.atguigu.day08.bean.test07.Rectangle;


public class Test08 {
    public static void main(String[] args) {
        Rectangle[] rectangles = new Rectangle[5];
        for (int i = 0; i < rectangles.length; i++) {
            rectangles[i] = new Rectangle();
            rectangles[i].setLength(Math.random() * 9 + 1);
            rectangles[i].setWidth(Math.random() * 9 + 1);
            rectangles[i].getInfo();
        }
        for (int j = 0; j < rectangles.length; j++) {
            for (int i = 0; i < rectangles.length - 1; i++) {
                if (rectangles[i].getArea() > rectangles[i + 1].getArea()) {
                    Rectangle temp = new Rectangle();
                    temp = rectangles[i];
                    rectangles[i] = rectangles[i + 1];
                    rectangles[i + 1] = temp;
                }
            }
        }
        System.out.println("*******排序后***********");
        for (int i = 0; i < rectangles.length; i++) {
            rectangles[i].getInfo();
        }
    }
}

